﻿using System;
using System.Collections.Generic;
using NServiceBus.Saga;

namespace Subscriber1
{
    public class SagaHeader : IContainSagaData
    {

        public virtual int ProcessId { get; set; }
        public virtual DateTime? BeginDate { get; set; }
        public virtual DateTime? EndDate { get; set; }
        public virtual string CompletionMessage { get; set; }
        public virtual ICollection<SagaUpdates> Children { get; set; }

        /// <summary>
        /// The 3 last properties belong to the 
        /// SagaData and is intented for internal use 
        /// only
        /// </summary>
        public virtual Guid Id { get;set; }
        public virtual string Originator { get; set; }
        public virtual string OriginalMessageId { get; set; }

        public virtual void AddChild(SagaUpdates child)
        {
            if(Children==null)
            {
                Children = new List<SagaUpdates>();
            }
            child.Parent = this;
            child.ProcessId = this.ProcessId;
            Children.Add(child);
        }
    }

    public class SagaUpdates
    {
        public virtual Guid Id { get; set; }
        public virtual int SomeMoreInformation { get; set; }
        public virtual string SomeMoreInformation2 { get; set; }
        public virtual int ProcessId { get; set; }
        public virtual SagaHeader Parent { get; set; }
        
    }
}
